<!DOCTYPE html>
<html>
<head>
<title>Relativistic Moving Mirror Diagram</title>
<style>
    body {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        margin: 0;
        background-color: #f0f0f0;
    }
    canvas {
        border: 1px solid #ccc;
        background-color: white;
    }
</style>
</head>
<body>
<canvas id="physicsCanvas" width="500" height="400"></canvas>
<script>
    const canvas = document.getElementById('physicsCanvas');
    const ctx = canvas.getContext('2d');

    // Style settings to mimic a hand-drawn look
    ctx.strokeStyle = 'black';
    ctx.fillStyle = 'black';
    ctx.lineWidth = 2.5;
    ctx.lineCap = 'round';
    ctx.lineJoin = 'round';

    // Helper function to draw an arrow
    function drawArrow(fromX, fromY, toX, toY, headLength = 10) {
        const dx = toX - fromX;
        const dy = toY - fromY;
        const angle = Math.atan2(dy, dx);
        
        ctx.beginPath();
        ctx.moveTo(fromX, fromY);
        ctx.lineTo(toX, toY);
        ctx.stroke();

        ctx.beginPath();
        ctx.moveTo(toX, toY);
        ctx.lineTo(toX - headLength * Math.cos(angle - Math.PI / 6), toY - headLength * Math.sin(angle - Math.PI / 6));
        ctx.moveTo(toX, toY);
        ctx.lineTo(toX - headLength * Math.cos(angle + Math.PI / 6), toY - headLength * Math.sin(angle + Math.PI / 6));
        ctx.stroke();
    }

    // --- Main Drawing ---

    const ox = 120;
    const oy = 175;

    // Draw x-axis (x, x')
    drawArrow(ox - 20, oy, ox + 350, oy);
    ctx.font = "italic 22px 'Times New Roman'";
    ctx.fillText("x, x'", ox + 355, oy + 8);

    // Draw y-axis (Σ)
    drawArrow(ox, oy + 100, ox, oy - 100);
    ctx.fillText('y', ox + 8, oy - 105);
    ctx.font = "24px 'Times New Roman'";
    ctx.fillText('Σ', ox - 8, oy + 125);

    // Draw the mirror (Σ')
    const mirrorX = ox + 80;
    const mirrorTopY = oy - 90;
    const mirrorBottomY = oy + 90;
    
    ctx.beginPath();
    ctx.moveTo(mirrorX, mirrorTopY);
    ctx.lineTo(mirrorX, mirrorBottomY);
    ctx.stroke();

    // Draw hatching on the mirror
    ctx.lineWidth = 2;
    for (let y = mirrorTopY + 15; y < mirrorBottomY; y += 15) {
        ctx.beginPath();
        ctx.moveTo(mirrorX, y);
        ctx.lineTo(mirrorX - 10, y - 10);
        ctx.stroke();
    }
    ctx.lineWidth = 2.5; // Reset line width

    // Labels for the mirror frame
    ctx.font = "italic 22px 'Times New Roman'";
    ctx.fillText("y'", mirrorX + 8, mirrorTopY - 5);
    ctx.font = "24px 'Times New Roman'";
    ctx.fillText("Σ'", mirrorX - 10, oy + 125);

    // Draw velocity vector 'v'
    const vArrowY = oy - 60;
    drawArrow(mirrorX + 70, vArrowY, mirrorX + 20, vArrowY);
    ctx.font = "italic 22px 'Times New Roman'";
    ctx.fillText('v', mirrorX + 40, vArrowY - 5);

    // Draw light beam
    const lightArrowY = oy;
    drawArrow(ox + 300, lightArrowY, ox + 220, lightArrowY);
    ctx.font = "bold 20px 'Times New Roman'";
    ctx.fillText('light', ox + 245, lightArrowY - 10);

    // Draw Figure caption
    ctx.font = "20px 'Times New Roman'";
    ctx.textAlign = 'center';
    ctx.fillText('Fig. 3.9.', canvas.width / 2, 350);

</script>
</body>
</html>